<template>
  <div id="app">
    <template v-for="(item, index) in arr">
      <div :key="index" v-if="!item.meta.hidden">
        <router-link :to="item.path"> {{ item.meta.title }}</router-link>
      </div>
    </template>
    <button @click="login">登录</button>
    <button @click="esc">退出</button>
    <router-view></router-view>
  </div>
</template>

<script>
import useaddRoute from "./utils/loadingRouter";
export default {
  data() {
    return {
      arr: [],
    };
  },
  created() {
    useaddRoute();
    this.arr = this.$store.getters.updateNav;
  },
  name: "App",
  methods: {
    async login() {
      await this.$store.dispatch("updateStoreChange", true);
      let isLogin = await this.$store.getters.updateStore;
      isLogin ? useaddRoute() : "";
    },
    async esc() {
      await this.$store.dispatch("updateStoreChange", false);
      let isLogin = await this.$store.getters.updateStore;
      isLogin ? "" : location.reload();
    },
  },
};
</script>

<style>
</style>
